package com.more.offer.designpatterns.composition;

import com.sun.deploy.perf.DeployPerfUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author pinoc
 * @date 2021/10/28
 * @description
 */
public class RootDepartment extends Department{

	private List<Department> deptList = new ArrayList<>();

	public RootDepartment(String name) {
		super(name);
	}

	public RootDepartment() {
	}

	@Override
	public void addDept(Department dept) {
		deptList.add(dept);
	}

	@Override
	public void showDept(int depth) {
		StringBuilder sb = new StringBuilder("");
		for (int i = 0; i < depth; i++) {
			sb.append("-");
		}
		System.out.println(new String(sb) + this.getName());
		for (Department c : deptList) {
			c.showDept(depth + 2);
		}
	}
}
